import { AxiosResponse } from "axios";
import { message } from "antd";
const error = (result: AxiosResponse, callback?: any) => {
  try {
    if (result?.data?.code === 0) {
      //success
      return result.data?.data;
    } else {
      message.error(result?.data?.message || "出错了");
      callback && callback([]);
      throw new Error(result.data.message);
    }
  } catch (error: any) {
    message.error(error?.message);
    console.log(error?.message);
  }
};
export default error;
